({
    //查询数据
    doReturnData: function (component, event, helper) {
        //设置当前页
        component.set("v.currentPage", 1);
        helper.returnData(component);
    },
    // 上一页
    prePage: function (component, event, helper) {
        //获取当前页的值
        var currentPage = component.get("v.currentPage");
        component.set("v.currentPage", currentPage - 1);
        helper.returnData(component);
    },
    //下一页
    nextPage: function (component, event, helper) {
        var currentPage = component.get("v.currentPage");
        component.set("v.currentPage", currentPage + 1);
        helper.returnData(component);
    },
  
    /* 
        //全选
        selectAll: function (component, event, helper) {
            var selectedValue = event.getSource().get("v.value");
            var allCheckboxes = component.find("checkbox");
            if (Array.isArray(allCheckboxes)) {
                allCheckboxes.forEach(function (checkbox) {
                    checkbox.set("v.value", selectedValue);
                });
            } else {
                allCheckboxes.set("v.value", selectedValue);
            }
        }, */
    //单选
    onCheck: function (component, event, helper) {
        var checkCmp = component.find("checkbox");
        var resultCmp = component.find("checkResult");
        resultCmp.set("v.value", "" + checkCmp.get("v.value"));
    },
    // 全选
    selectAll: function (component, event, helper) {
        var isAllSelected = component.get("v.isAllSelected");

        // 更新所有行的选中状态
        var checkboxes = component.find("checkbox");
        checkboxes.forEach(function (checkbox) {
            checkbox.set("v.value", isAllSelected);
        });

        // 获取当前表格的所有记录Id
        const data = component.get("v.resData");
        var ids = data.map(function (item) {
            return item.Id;
        });
        // console.log('ids:', ids);
        // 更新选中行的数据
        if (isAllSelected) {
            component.set("v.selectedRows", ids);
        } else {
            component.set("v.selectedRows", []);
        }
    },
    // 选中行
    selectRow: function (component, event, helper) {
        var isAllSelected = component.get("v.isAllSelected");
        // 保存选中的id
        var ids = component.get("v.selectedRows");
        // 获取当前行的记录id
        var rowId = event.getSource().get("v.class");
        console.log(rowId);
        // 如果当前行复选框是选中状态就 添加id到ids，否则过滤掉ids中的id
        if (event.getSource().get("v.value")) {
            ids.push(rowId);
        } else { // 过滤id
            ids = ids.filter(function (item) {
                return item !== rowId;
            });
        }
        console.log('bbb');
        console.log(ids);
        component.set("v.selectedRows", ids);
        // 设置复选框是否被全选
        component.set("v.isAllSelected", ids.length === component.get("v.resData").length);
    },
    // 转正申请
    doRegular: function (component, event, helper) {
        console.log('hhhh');
        component.set('v.doCondition', 'doRegular');
        helper.returnData(component);
        component.set('v.doCondition', 'init');
        // location.reload();
        // 将选择数据制空
        component.set("v.selectedRows", []);
        // 清除复选框勾选记录
        component.set('v.isAllSelected', false);
        var isAllSelected = component.get("v.isAllSelected");
        // 更新所有行的选中状态
        var checkboxes = component.find("checkbox");
        checkboxes.forEach(function (checkbox) {
            checkbox.set("v.value", isAllSelected);
        });
    },

})
